const $http = (op: {
    url: string,
    data: object,
    method: any
}) => {
    let header: object = { "Content-Type": op.method.toUpperCase() == 'POST' ? "application/x-www-form-urlencoded" : "application/json" };
    return new Promise((fn1, fn2) => {
        wx.request({
            ...op,
            header,
            success({ data }) {
                fn1(data)
            },
            fail(err) {
                fn2(err)
            }
        })
    })
}
const $login = (op:{
    timeout:number
})=>{
    return new Promise((fn1,fn2)=>{
        wx.login({
            ...op,
            success(res){
                fn1(res)
            },
            fail(err){fn2(err)}
        })
    })
}
module.exports = {
    $http,
    $login
}